package com.blog.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blog.service.UserService;
import com.blog.service.Impl.UserServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;


@WebServlet("/User.do")
public class LikeUserServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		UserService us=new UserServiceImpl();
		int userId = request.getParameter("userId") ==null ? 1 : Integer.parseInt(request.getParameter("userId"));
		response.setContentType("application/json;charset=utf-8");
		new ObjectMapper().writeValue(response.getWriter(), us.selectById(userId));
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
